<template>
  <h1>{{ msg }}</h1>
  <p @click="$store.commit('add')">{{$store.state.count}}</p>
  <comp></comp>
  <p>
    Recommended IDE setup:
    <a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
    +
    <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
  </p>

  <p>
    <a href="https://vitejs.dev/guide/features.html" target="_blank">
      Vite Documentation
    </a>
    |
    <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
  </p>

  <button type="button" @click="count++">count is: {{ count }}</button>
  <el-button @click="onclick">emits</el-button>
  <el-input></el-input>
</template>

<script setup>
// 1.直接导入组件
import Comp from 'comps/Comp.vue'
import { ref } from 'vue'
import request from "utils/request";

// 2.属性定义
const props = defineProps({
  msg: String
})
console.log(props);

// 3.获取上下文
//const ctx = useAttrs() // useContext()
//console.log(ctx);

// 4.定义事件
const emits = defineEmits(['myclick'])
const count = ref(0)
const onclick = () => {
  emits('myclick')
  //ctx.emits('myclick')
}

 // 请求mock api
//  fetch('/api/getUsers')
//    .then((res) => res.json())
//     .then((data) => {
//       console.log(data)
//     });

// try{
//   const user = await request('/getUsers')
//   console.log(users);
// }
// catch(error) {
//   console.log(error)
// }

</script>